package com.mew.user.service;

import com.mew.common.dc.db.UserService;
import com.mew.common.dc.mapper.UserMapper;
import com.mew.common.dc.redis.GameRoomRedisService;
import com.mew.common.entity.user.User;
import com.mew.common.rest.user.UserDetailedInfoResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author dylin
 * @create 2021/1/27 0027
 */
@Service
public class UserInfoService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private UserService userService;
    @Autowired
    private GameRoomRedisService gameRoomRedisService;
    @Autowired
    private LevelConfigService levelConfigService;


    public UserDetailedInfoResponseMessage getDetailedInfo(long uid,long qid){
        User user=userService.getRedisUserById(qid);
        if(user==null ){
            return null;
        }
        return UserDetailedInfoResponseMessage.builder()
                .id(user.getId())
                .gid(user.getGid())
                .headPath(user.getHeadPath())
                .nickname(user.getNickname())
                .signature(user.getSignature())
                .build();
    }

    public UserDetailedInfoResponseMessage getDetailedInfo(long uid,String gid){
        User user=userService.getUserByGid(gid);
        if(user==null){
            return null;
        }
        if(user==null){
            return null;
        }
        return UserDetailedInfoResponseMessage.builder()
                .id(user.getId())
                .gid(user.getGid())
                .headPath(user.getHeadPath())
                .nickname(user.getNickname())
                .signature(user.getSignature())
                .build();
    }


}
